home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / util / boot / Kill2090.lha / Kill2090 / kill2090.s < prev    next >
Text File  |  2001-03-06  |  8KB  |  314 lines

  1. ; kill 2090 - by J Davis 08/1990
  2. ; ---------
  3. ;
  4. ; version 1.0 
  5. ;
  6. ; THIS MUST BE ASSEMBLED TO FORCELOAD TO CHIPMEM!!!
  7. ;
  8. ; very simple program to reboot 2000 with all autoconfig boards off
  9. ;
  10. ; this allows you to boot off floppies without worrying about
  11. ; rogue programs attacking your hard-disk
  12. ; the drive is only killed until the next reboot - so ctrl-amiga-amiga
  13. ; will re-anable it
  14. ; how it does it -
  15. ;                 this is basically a modified version of the 'official'
  16. ;                 reboot code in the rkm:hardware, with the addition of
  17. ;          a coldcapture routine that 'fakes out' all the expansion 
  18. ;          boards, stopping exec from seeing/using them
  19. ;
  20. ; YES THIS IS A HACK!! It manipulates the system in a manner contrary
  21. ; to the rkm quidelines - so don't blame me if it doesn't work!! :-)
  22. ;
  23. ;
  24. ; changes for version .05(beta)
  25. ;
  26. ;    sends 5 flashes when cold capt code starts
  27. ;    back to brute force approach to finding all boards
  28. ;
  29. ; changes for version .06(beta)
  30. ;
  31. ;    now sends all boards that don't support shut_up to $200000
  32. ;    ( instead of $d00000 as before ). This gets around problems
  33. ;    with memory boards overlaying the custom chips and killing the
  34. ;    whole system
  35. ;
  36. ; changes for version 1.0 
  37. ;    added code to switch super agnus to PAL/NTSC
  38. ;
  39. ;    by altering the conditional compilation switches Go_NTSC and
  40. ;    Kill_boards, you can set whether to switch to PAL or NTSC at
  41. ;    boot-time, and also whether to just reset, or kill exp boards
  42. ;    as well, giving four possible versions of this program
  43.  
  44.  
  45. ;===========================================================
  46. ; vary these flags to build all 4 possible versions
  47.  
  48. kill_boards    equ    0    ; set to 0 to just build reset program
  49.  
  50. go_ntsc        equ    0    ; set to 1 will toggle superAgnus to NTSC
  51.                 ; set to 0 will toggle to PAL
  52.  
  53. ;=============================================
  54.  
  55. forbid        equ    -$084    ; offsets for various exec and int calls
  56. getmsg        equ    -$174    ; saves long includes and compile times
  57. replymsg    equ    -$17a
  58. waitport    equ    -$180
  59. findtask    equ    -$126
  60. autoreq        equ    -$15c
  61. openlib        equ    -$228
  62. closelib    equ    -$19e
  63. supervisor    equ     -$01e    
  64.  
  65. attnflags    equ    $128    ; offset for execbase.attnflags word
  66. afb_68020    equ    1<<1    ; bit mask for 020 flag
  67.  
  68. pr_cli        equ    $0Ac    ; process cli flag offset
  69. pr_msgport    equ    $05c    ; process msgport offset
  70.  
  71. ; hisoft devpac and Argasm don't support the 010+ movec command!
  72. ; so we jam them in as consts instead
  73. movec_cacr_d0    equ     %0000000000000010
  74. movec_d0_cacr    equ    %1000000000000010
  75.  
  76. ;=========================================
  77.  
  78.         section    main,code_c        ; make sure we're in CHIP
  79.  
  80. startup:    move.l    $4,a6
  81.         move.l    #0,a1
  82.         jsr    findtask(a6)        ; find ourselves
  83.  
  84.         move.l    d0,a4            ; save our process pointer
  85.  
  86.         move.l    pr_cli(a4),d0
  87.         bne    fromdos            ; was a DOS startup
  88.  
  89.         ; was started from WB
  90.  
  91.         lea    pr_msgport(a4),a0
  92.         jsr    waitport(a6)        ; wait for startup msg
  93.         lea    pr_msgport(a4),a0
  94.         jsr    getmsg(a6)        ; get the wb msg
  95.  
  96.         move.l    d0,wbmsg        ; save pointer to our startup msg
  97.         move.l    #1,wb            ; flag we started from wb
  98.  
  99. fromdos:    lea    intuiname,a1
  100.         move.l    #0,d0
  101.         move.l    $4,a6
  102.         jsr    openlib(a6)         ; open intuition lib
  103.  
  104.         move.l    d0,a6            ; save ibase
  105.         
  106.         move.l    #0,a0            ; window to display in
  107.         move.l    #bodyitext,a1        ; body text
  108.         move.l    #yesitext,a2         ; postive text
  109.         move.l    #noitext,a3          ; negative text
  110.         move.l    #0,d0            ; pflags
  111.         move.l    #0,d1            ; nflags
  112.         move.l    #460,d2            ; width
  113.         move.l    #60,d3            ; height
  114.         jsr    autoreq(a6)        ; request user confirmation
  115.  
  116.         cmp.l    #0,d0
  117.         bne    reboot            ; user selected ok, kill!
  118.  
  119.         ; user cancelled reboot
  120.         
  121.         move.l    a6,a1            ; close intuition lib
  122.         move.l    $4,a6
  123.         jsr    closelib(A6)
  124.         
  125. exit:        move.l    wb,d0
  126.         cmp.l    #0,d0            ; was this a CLI invocation
  127.         beq    exit_dos
  128.  
  129.         ; workbench exit
  130.  
  131.         move.l    $4,a6
  132.         jsr    forbid(a6)        ; lock out everyone else
  133.  
  134.         move.l    wbmsg,a1
  135.         jsr    replymsg(a6)        ; reply to Wbstartup msg
  136.  
  137. exit_dos:    move.l    #0,d0            ; return with return code 0
  138.         rts            
  139.  
  140.  
  141.  
  142. ;=====================================
  143. ; the following does the actual reboot 
  144.         
  145. reboot:        jsr    instcold        ; install coldcapture handler
  146.                         ; exec will run coldcapt once and then
  147.                         ; kill it - exactly what we want!    
  148.     
  149.         move.l    $4,a6             ; RESET must be run in Smode, so go to it
  150.         move.l    #reboot_c,a5        ; code to run in supervisor mode
  151.         jsr    supervisor(A6)        ; go into supervisor mode
  152.  
  153.         cnop    0,4            ; longword align code
  154.         
  155. reboot_c:    move.l    $4,a6
  156.         btst.b    #afb_68020,attnflags+1(a6)
  157.         beq    kill            ; is system 020/030 powered ?
  158.  
  159.         ; if it is an 020 or 030, take extra steps for cache 
  160.     
  161.         dc.w    movec_cacr_d0       ; twiddle the cache control reg
  162.         bset.l    #3,d0
  163.         dc.w    movec_d0_cacr
  164.      
  165.          bra    kill
  166.      
  167.          cnop    0,4            ; long word align code
  168.  
  169. kill:        move.l    #$2,a1            ; where to jump to in rom
  170.         reset
  171.         jmp (a1)            ; now run reset code in rom
  172.  
  173.  
  174.  
  175. ;=======================================
  176. ; routine to install coldcapture handler
  177.  
  178. instcold:    move.l    $4,a6            ; get execbase
  179.         lea    cold,a0            ; get address of our coldcapt routine
  180.         move.l    a0,$2a(a6)        ; set coldcapture vect
  181.  
  182.         lea    34(a6),a0        ; start of checksummed area in execbase
  183.         move.w    #$16,d0            ; number of checksummed words
  184.         move.w    #$0,d1            ; clear counter
  185.     
  186. sum:        add.w    (A0)+,d1        ; sum execbase and update checksum
  187.         dbf    d0,sum
  188.     
  189.         not.w    d1
  190.         move.w    d1,82(a6)        ; save fixed checksum
  191.  
  192.         rts
  193.  
  194.  
  195. ;===========================================================================
  196. ; our actual cold capture handler, flashes led,zaps boards,toggles agnus etc
  197.  
  198. cold:        move.w    #$0f8a,$dff180    ; set screen colour to pink
  199.  
  200.     IFNE     go_ntsc        ; go_ntsc=1 switch to ntsc
  201.         move.w    #$00,$dff1dc    ; set NTSC mode on agnus
  202.     ELSEIF
  203.         move.w    #$20,$dff1dc    ; set PAL mode on agnus
  204.     ENDC
  205.  
  206.  
  207.         move.l    #9,d0            ; flash power led 5 times 
  208.                         ; to let know we're running
  209.  
  210. lloop:        bchg    #1,$bfe001        ; toggle led
  211.         move.l    #$ffff,d1
  212. lwait:        dbf    d1,lwait        ; delay
  213.         dbf    d0,lloop
  214.  
  215.  
  216.     IFNE    kill_boards            ; kill_boards=1, so add kill code
  217.  
  218.         move.l    #$7,d1            ; max no boards we fix = 8 
  219.  
  220. bchk:        move.w    $e80008,d0        ; get flag byte from board
  221.         not.w    d0            ; invert
  222.         btst.l    #14,d0            ; see if board supports shut_up
  223.         beq    shut_up            ; bit=0 means board shuts up ok
  224.  
  225.         ; board doesn't support shut up, so 
  226.         ; config board to $200000 (only gap big enough for 8mb
  227.         ; boards)
  228.     
  229.         move.w    #$0000,$e8004a      ; fake board out to $200000
  230.         move.w    #$2000,$e80048  
  231.         
  232.         bra    nboard            ; carry on
  233.  
  234. shut_up:    move.b    #$ff,$e8004c        ; tell the board to shut up
  235.  
  236. nboard:        dbf    d1,bchk            ; loop thru all boards
  237.     ENDC
  238.  
  239. bexit:        jmp    (a5)            ; chain thru to rest of reset routine
  240.     
  241. ;=============================================================
  242.         
  243. wb:        dc.l    0            ; run mode flag 0=dos process 1=wbprocess
  244. wbmsg:        dc.l    0            ; where we save our workbench msg
  245.  
  246. intuiname:    dc.b    "intuition.library",0
  247.  
  248. ; stuff for our autorequester
  249.  
  250. bodyitext:    dc.b    0           ; front pen
  251.         dc.b    1           ; back pen
  252.         dc.b    0           ; draw mode
  253.         dc.w    70           ; leftedge
  254.         dc.w    6           ; topedge
  255.         dc.l    0           ; textattr = default
  256.         dc.l    bodytext1      ; actual text
  257.         dc.l    bodyitext2     ; next
  258.  
  259. bodyitext2:    dc.b    0           ; front pen
  260.         dc.b    1           ; back pen
  261.         dc.b    0           ; draw mode
  262.         dc.w    35           ; leftedge
  263.         dc.w    15          ; topedge
  264.         dc.l    0           ; textattr = default
  265.         dc.l    bodytext2     ; actual text
  266.         dc.l    0            ; next
  267.  
  268.         
  269. yesitext:    dc.b    2        ; front pen
  270.         dc.b    1        ; back pen
  271.         dc.b    0        ; draw mode
  272.         dc.w    4        ; leftedge
  273.         dc.w    4        ; topedge
  274.         dc.l    0        ; textattr = default
  275.         dc.l    yestext        ; actual text
  276.         dc.l    0        ; next
  277.         
  278. noitext:    dc.b    2        ; front pen
  279.         dc.b    1        ; back pen
  280.         dc.b    0        ; draw mode
  281.         dc.w    4        ; leftedge
  282.         dc.w    4        ; topedge
  283.         dc.l    0        ; textattr = default
  284.         dc.l    notext        ; actual text
  285.         dc.l    0        ; next        
  286.  
  287.         ; actual text for our requester
  288.  
  289.     IFNE    kill_boards
  290. bodytext1:    dc.b    "Kill2090"
  291.         ELSEIF
  292. bodytext1:    dc.b    " Reset"
  293.     ENDC
  294.         
  295.         dc.b     " by J Davis, 08-1990 v1.0 "
  296.  
  297.     IFNE    go_ntsc    
  298.         dc.b    "NTSC"
  299.     ELSEIF
  300.         dc.b    "PAL "
  301.     ENDC
  302.         dc.b    0
  303.  
  304. bodytext2:    dc.b    "About to kill system, finish ALL disk activity",0
  305.  
  306. yestext:    dc.b    "Go ahead, make my day!",0
  307. notext:        dc.b    "No, I was just kidding!",0
  308.  
  309.         END
  310.